package com.transaction.stockseata.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.transaction.stockseata.mapper.StockMapper;
import com.transaction.stockseata.pojo.Stock;
import com.transaction.stockseata.service.StockService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 */
@Service
public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements StockService{

    @Autowired
    private StockMapper stockMapper;

    @Override
    public String deduct(Integer productId) {
        int i = stockMapper.updateCountByProductId(1, productId);
        if (i != 1 ) {
            return "库存扣除失败。。。";
        }
        return "库存扣减成功";
    }
}




